package com.music.set;

import com.music.R;
import com.music.player.PlayerService;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;

public class PatternActivity extends Activity{
	RadioGroup group;
	RadioButton r1;
	RadioButton r2;
	RadioButton r3;
	Button b1;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.pattern);
		group=(RadioGroup)findViewById(R.id.radioGroup1);
		r1=(RadioButton)findViewById(R.id.radioButton1);
		r2=(RadioButton)findViewById(R.id.radioButton2);
		r3=(RadioButton)findViewById(R.id.radioButton3);
		if(PlayerService.pattern==0){
			r1.setChecked(true);
		}else if(PlayerService.pattern==1){
			r2.setChecked(true);
		}else if(PlayerService.pattern==2){
			r3.setChecked(true);
		}
		group.setOnCheckedChangeListener(new OnCheckedChangeListener() {
			
			@Override
			public void onCheckedChanged(RadioGroup arg0, int rid) {
				// TODO Auto-generated method stub
				if(rid==R.id.radioButton1){
					PlayerService.pattern=0;
				}else if(rid==R.id.radioButton2){
					PlayerService.pattern=1;
				}else if(rid==R.id.radioButton3){
					PlayerService.pattern=2;
				}
			}
		});
		b1=(Button)findViewById(R.id.set_button1);
		b1.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				PatternActivity.this.finish();
			}
		});
	}
}
